import request from '@/utils/axios';
import { UserListResponse, UserResponse, UserInfoListResponse } from './modules/userModule';

export const apiList = {
    userList: '/admin/user/list',
    addUser: '/admin/user/add',
    editUser: '/admin/user/edit',
    deleteUser: '/admin/user/delete',
    UserInfoList: '/admin/user_info/list',
    editUserInfo: '/admin/user_info/edit',
    changeUserStatus: '/admin/user/active',
};

export const getUserList = (params: object): Promise<UserListResponse> => {
    return request({
        url: apiList.userList,
        method: 'get',
        params: params
    });
};

export const addUser = (params: object): Promise<UserResponse> => {
    return request({
        url: apiList.addUser,
        method: 'post',
        data: params
    });
};

export const editUser = (params: object): Promise<UserResponse> => {
    return request({
        url: apiList.editUser,
        method: 'put',
        data: params
    });
};

export const deleteUser = (params: object): Promise<UserResponse> => {
    return request({
        url: apiList.deleteUser,
        method: 'delete',
        data: params
    });
};

export const getUserInfo = (params: object): Promise<UserInfoListResponse> => {
    return request({
        url: apiList.UserInfoList,
        method: 'get',
        params: params
    });
};

export const editUserInfo = (params: object): Promise<UserInfoListResponse> => {
    return request({
        url: apiList.editUserInfo,
        method: 'put',
        data: params
    });
};

export const changeUserStatus = (params: object): Promise<UserResponse> => {
    return request({
        url: apiList.changeUserStatus,
        method: 'put',
        data: params
    });
};

